'use strict';

angular.module('app')
    .controller('detailController', ['$scope', '$rootScope', '$state', '$timeout',
        function($scope, $rootScope, $state, $timeout) {
            var title = "资讯详情";
            var id = $state.params.id;
            $scope.title = $rootScope.title = title;
            $scope.loading = true;
            
            UE.delEditor("messageContent");
            var ue = UE.getEditor('messageContent');
            
            // 初始化页面
            $scope.activate = function (id) {
                $scope.loading = true;
                $.ajax({
                    url : $scope.app.project_name + '/messagePlat/read/detail',
                    data: {'id': id}
                }).then(function(result) {
                    $scope.loading = false;
                    if (result.httpCode == 200) {
                        $scope.record = result.data;
                        
                        if (1 == $scope.record.requestFlag) {
                    		UE.getEditor('messageContent').setContent($scope.record.messageContent);
                    	}
                    } else {
                        $scope.msg = result.msg;
                    }
                    $scope.$apply();
                });
            }
            
            $scope.activate(id);

    } ]);